package com.lxw.learning.service;

import com.lxw.framework.domain.course.TeachplanMediaPub;
import com.lxw.framework.domain.learning.response.GetMediaResult;
import com.lxw.framework.exception.ExceptionCast;
import com.lxw.framework.model.response.CommonCode;
import com.lxw.learning.client.CourseLearningClient;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 */
@Service
public class CourseLearningService {
    @Autowired
    private CourseLearningClient courseLearningClient;

    public GetMediaResult getmedia(String courseId, String teachplanId) {
        //权限处理

        //调用搜索服务,远程获取课程媒资信息
        TeachplanMediaPub teachplanMediaPub = courseLearningClient.getmedia(teachplanId);
        if (teachplanMediaPub !=null && StringUtils.isNotEmpty(teachplanMediaPub.getMediaUrl())){
            String mediaUrl = teachplanMediaPub.getMediaUrl();
            return new GetMediaResult(CommonCode.SUCCESS,mediaUrl);
        }else {
            ExceptionCast.cast(CommonCode.FAIL);
            return null;
        }
    }
}
